#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12 height-auto">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <p style="float:right">
                        <label class="table-search-title-first">表名</label>
                        <input type="text" id="tablename" lay-verify="required" placeholder="" autocomplete="off"
                               class="table-search-text width80">
                        <label class="table-search-title">表说明</label>
                        <input type="text" id="tabletitle" lay-verify="required" placeholder="" autocomplete="off"
                               class="table-search-text width120">
                        <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                            搜索
                        </button>
                    </p>
                    <i class="layui-icon layui-icon-triangle-r"></i>
                    当前位置 > <span class="color_green">开发代码生成列表</span>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container">
                            <button class="layui-btn layui-btn-sm btn-add" lay-event="AddSysCode">添加数据表</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="EditSysCode">修改</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-more="btn-del" lay-event="DelSysCode">删除</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-change-8" lay-event="SysCodeColumn">列表配置</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-change-3" lay-event="SysCodeForm">表单配置</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-change-13" lay-event="ViewSysCode">查看代码</button>
                        </div>
                    </script>

                    <script type="text/html" id="table_1_bar1">
                        <div class="layui-btn-container">
                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="EditSysCode">修改</a>
                            <a class="layui-btn layui-btn-xs btn-change-8" lay-event="SysCodeColumn">列表</a>
                            <a class="layui-btn btn-change-3 layui-btn-xs" lay-event="SysCodeForm">表单</a><a class="layui-btn btn-change-13 layui-btn-xs" lay-event="ViewSysCode">代码</a>
                        </div>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">
    var USER_JWT = "";
    var index = 0;
    var myTable, table, tableindex;

    layui.use(['myTable', 'table', 'form', 'util', 'myTool'], function () {
        var $ = layui.$;
        myTable = layui.myTable, table = layui.table
        form = layui.form, util = layui.util, myTool = layui.myTool;

        tableindex = myTable.render({
            url: 'SysCodeListDataApi', title: '代码生成表'
            , cols: [[
                {type: 'checkbox'}
                , {field: 'c_id', title: 'ID', width: 50, align: 'center'}
                , {field: 'table_name', title: '表名', align: 'left', width: 150}
                , {field: 'table_title', title: '表说明', align: 'left', width: 120}
                , {field: 'package_name', title: '包目录', align: 'left', width: 180}
                , {field: 'c_desc', title: '备注说明'}
                , {fixed: 'right', title: '操作', toolbar: '#table_1_bar1', width: 180, align: 'center'}
            ]]
            , page: true, limit: 10
            , serviceSort: true, initSort: {field: 'c_id', type: 'desc'}
        });

        util.event("lay-event", {
            DoSearch: function () {
                tableindex.reload({
                    where: {
                        s: {tablename: $("#tablename").val(), tabletitle: $("#tabletitle").val()}
                    }
                    , page: {curr: 1}
                });
            }
        });


        /**
         * 工具栏事件
         */
        layui.table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                AddSysCode: function () {
                    index = top.layer.open({
                        type: 2, offset: '60px', area: ['760px', '550px'], title: ['添加表数据', 'font-size:15px;'],
                        content: ["syscode/AddSysCode", 'no'],
                        end: function () {
                            tableindex.reload({});
                        }
                    });
                }
                , EditSysCode: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '60px', area: ['760px', '550px'], title: ['修改表[' + data[0].table_name + ']', 'font-size:15px;'],
                            content: ["syscode/EditSysCode?c_id=" + data[0].c_id, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , DelSysCode: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.confirm('你是否确认删除【' + data[0].table_name + '】', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                            myTool.post("DelSysCodeApi", {c_id: data[0].c_id}, function () {
                                tableindex.reload();
                            });
                        });
                    });
                }
                , SysCodeColumn: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '20px', area: ['1150px', '572px'],
                            title: ['列表配置[' + data[0].table_name + ']' + data[0].table_title, 'font-size:15px;color:green'],
                            content: ["syscode/SysCodeColumnList?c_id=" + data[0].c_id, 'no']
                        });
                    });
                }
                , SysCodeForm: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '20px', area: ['1220px', '572px'],
                            title: ['表单配置[' + data[0].table_name + ']' + data[0].table_title, 'font-size:15px;color:green'],
                            content: ["syscode/SysCodeFormList?c_id=" + data[0].c_id, 'no']
                        });
                    });
                }
                , ViewSysCode: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '30px', area: ['1100px', '550px'],
                            title: ['生成代码[' + data[0].table_name + ']' + data[0].table_title, 'font-size:15px;color:green'],
                            content: ["syscode/ViewSysCode?c_id=" + data[0].c_id, 'no']
                        });
                    });
                }
            });
        });


        /**
         * 工具栏事件
         */
        layui.table.on('tool(table_1)', function (obj) {
            myTool.tool(this, obj, {
                EditSysCode: function (data) {
                    index = top.layer.open({
                        type: 2, offset: '60px', area: ['760px', '550px'], title: ['修改表[' + data.table_name + ']', 'font-size:15px;'],
                        content: ["syscode/EditSysCode?c_id=" + data.c_id, 'no'],
                        end: function () {
                            tableindex.reload({});
                        }
                    });
                }
                , SysCodeColumn: function (data) {
                    index = top.layer.open({
                        type: 2, offset: '20px', area: ['1150px', '572px'],
                        title: ['列表配置[' + data.table_name + ']' + data.table_title, 'font-size:15px;color:green'],
                        content: ["syscode/SysCodeColumnList?c_id=" + data.c_id, 'no']
                    });
                }
                , SysCodeForm: function (data) {
                    index = top.layer.open({
                        type: 2, offset: '20px', area: ['1220px', '572px'],
                        title: ['表单配置[' + data.table_name + ']' + data.table_title, 'font-size:15px;color:green'],
                        content: ["syscode/SysCodeFormList?c_id=" + data.c_id, 'no']
                    });
                }
                , ViewSysCode: function (data) {
                    index = top.layer.open({
                        type: 2, offset: '30px', area: ['1100px', '550px'],
                        title: ['生成代码[' + data.table_name + ']' + data.table_title, 'font-size:15px;color:green'],
                        content: ["syscode/ViewSysCode?c_id=" + data.c_id, 'no']
                    });
                }
            });
        });
    });
</script>
#include("../../comm/Foot.html")